package com.ljsw.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ljsw.activity.R;

/**
* @Package com.ljsw.dialog 
* @Description: TODO(Dialog) 
* @author 郑鸿博   
* @date 2015-11-27 下午2:22:13 
* @version V1.0
 */
public class LoadIngDialog {
	public LoadIngDialog(Context context) {
		super();
		this.context = context;
		WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		display = windowManager.getDefaultDisplay();//获取屏幕分辨率
	}
	private Context context;
	private Dialog dialog;
	private Display display;
	private LinearLayout lLayout_bg;
	private TextView txt;//标题
	private ImageView image;//
	private Animation anim;
	
	public LoadIngDialog builder(){
		// 获取Dialog布局
		View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
//		lLayout_bg = (LinearLayout) view.findViewById(R.id.lay_tijiao);
		txt = (TextView) view.findViewById(R.id.progress_dialog_txt);
		image = (ImageView) view.findViewById(R.id.progress_dialog_img);
		//给图片添加动态效果
        anim=AnimationUtils.loadAnimation(context, R.anim.loading_dialog_progressbar);
    //  image.setAnimation(anim);
		//添加Dialog样式
		dialog = new Dialog(context, R.style.LoginDialog);
		dialog.setContentView(view);
		dialog.setCanceledOnTouchOutside(false);// 设置点击Dialog外部任意区域不关闭Dialog	
		// 调整dialog背景大小
//		lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		return this;
	}
	
	public void show(){
		image.setAnimation(anim);
		dialog.show();
	}
	public void dismiss(){
		dialog.dismiss();
	}
}
